Inside Macintosh: QuickTime

Previous | Chapter Top | Chapter Contents | Next

Changing Sequence-Compression Parameters

This section describes the functions that allow your application to manipulate the parameters that control sequence compression and to get information about memory that the compressor has allocated. You can use these functions during the sequence-compression process. Your application establishes the default value for most of these parameters with the CompressSequenceBegin function (described on CompressSequenceBegin ). Some of these functions deal with parameter values that cannot be set when starting a sequence.

You can determine the location of the previous image buffer used by the Image Compression Manager by calling the GetCSequencePrevBuffer function.

You can set a number of compression parameters. Use the SetCSequenceFlushProc function to assign a data-unloading function to the operation. You can set the rate at which the Image Compression Manager inserts key frames into the compressed sequence by calling the SetCSequenceKeyFrameRate function. You can set the frame against which the compressor compares a frame when performing temporal compression by calling the SetCSequencePrev function. Finally, you can control the quality of the compressed image by calling the SetCSequenceQuality function.

SetCSequenceQuality

The SetCSequenceQuality function allows you to adjust the spatial or temporal quality for the current sequence.

pascal OSErr SetCSequenceQuality (ImageSequence seqID,
                                         CodecQ spatialQuality,
                                         CodecQ temporalQuality);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function.
spatialQuality
Specifies the desired compressed image quality. See "Compression Quality Constants" for available values.
temporalQuality
Specifies the desired sequence temporal quality. This parameter governs the level of compression you desire with respect to information between successive frames in the sequence. Set this parameter to 0 to prevent the compressor from applying temporal compression to the sequence. See "Compression Quality Constants," for other available values.

DESCRIPTION

The spatial quality parameter indicates the image quality you desire for each frame in the sequence, which governs the level of spatial compression that the compressor may apply to each frame. The temporal quality parameter indicates the sequence quality you desire, which in turn governs the amount of temporal compression that the compressor may apply to the sequence. The new quality parameters take effect with the next frame in the sequence.

You set the default spatial and temporal quality values for a sequence with the spatialQuality and temporalQuality parameters to the CompressSequenceBegin function. For details on CompressSequenceBegin , see CompressSequenceBegin .

If you change the quality settings while processing an image sequence, you affect the maximum image size that you may receive during sequence compression. Consequently, you should call the GetMaxCompressionSize function (described on GetMaxCompressionSize ) after you change the quality settings. If the maximum size has increased, you should reallocate your image buffers to accommodate the larger image size.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

SetCSequenceKeyFrameRate

The SetCSequenceKeyFrameRate function adjusts the key frame rate for the current sequence.

pascal OSErr SetCSequenceKeyFrameRate (ImageSequence seqID,
                                         long keyframerate);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
keyframerate
Specifies the maximum number of frames allowed between key frames. Key frames provide points from which a temporally compressed sequence may be decompressed. Use this parameter to control the frequency at which the compressor places key frames into the compressed sequence.
The compressor determines the optimum placement for key frames based upon the amount of redundancy between adjacent images in the sequence. Consequently, the compressor may insert key frames more frequently than you have requested. However, the compressor will never place fewer key frames than is indicated by the setting of the keyFrameRate parameter. The compressor ignores this parameter if you have not requested temporal compression (that is, you have set the temporalQuality parameter to the CompressSequenceBegin function to 0).
If you set this parameter to 0, the Image Compression Manager only places key frames in the compressed sequence when you call the CompressSequenceFrame function (described on CompressSequenceFrame ) and set the value of the codecFlagForceKeyFrame flag to 1 in the flags parameter. If you pass in any number other than 0 , it specifies the number of non-key frames between key frames. Set this parameter to 1 to specify all key frames, to 2 to specify every other frame as a key frame, to 3 to specify every third frame as a key frame, and so forth.

DESCRIPTION

The key frame rate for a sequence specifies the maximum number of frames allowed between key frames. Key frames provide points from which a temporally compressed sequence may be decompressed. The new key frame rate takes effect with the next image in the sequence. See "Defining Key Frame Rates" for more information about key frames.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

SEE ALSO

You set the default key frame rate for a sequence with the keyFrameRate parameter to the CompressSequenceBegin function (described on CompressSequenceBegin ).

GetCSequenceKeyFrameRate

The GetCSequenceKeyFrameRate function lets you determine the current key frame rate of a sequence.

pascal OSErr GetCSequenceKeyFrameRate (ImageSequence seqID,
                                         long *keyframerate);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
keyframerate
Contains a pointer to a long integer that specifies the maximum number of frames allowed between key frames. Key frames provide points from which a temporally compressed sequence may be decompressed.

SEE ALSO

You can set the key frame rate of a sequence with the SetCSequenceKeyFrameRate function, described in the previous section.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

SetCSequenceFrameNumber

The SetCSequenceFrameNumber function informs the compressor in use for the specified sequence that frames are being compressed out of order.

pascal OSErr SetCSequenceFrameNumber (ImageSequence seqID,
                                         long frameNumber);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
frameNumber
Specifies the frame number of the frame that is being compressed out of sequence.

DESCRIPTION

This information is only necessary for compressors that are sequence-sensitive.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

GetCSequenceFrameNumber

The GetCSequenceFrameNumber function returns the current frame number of the specified sequence.

pascal OSErr GetCSequenceFrameNumber (ImageSequence seqID,
                                         long *frameNumber);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
frameNumber
Contains a pointer to the current frame number of the sequence identified by the seqID parameter.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

SetCSequencePrev

The SetCSequencePrev function allows the application to set the pixel map and boundary rectangle used by the previous frame in temporal compression. This is useful if the application that is compressing has multiple buffers and wants to update the previous frame by switching buffer pointers instead of copying the data. Usually, the Image Compression Manager allocates the previous buffer for temporal compression. Under normal circumstances, the compressor component or the Image Compression Manager updates the contents of the buffer by copying each frame into the buffer after it is compressed.

This is a very specialized function--your application should not need to call it under most circumstances.

pascal OSErr SetCSequencePrev (ImageSequence seqID,
                                          PixMapHandle prev,
                                          const Rect *prevRect);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
prev
Contains a handle to the new previous image buffer. The compressor uses this buffer to store a previous image against which the current image (stored in the buffer referred to by the src parameter to the CompressSequenceBegin function) is compared when performing temporal compression. You must allocate this buffer using the same pixel depth and color table as the source image buffer that you specify with the src parameter when you call the CompressSequenceBegin function (described on CompressSequenceBegin ). The compressor manages the contents of this buffer based upon several considerations, such as the key frame rate and the degree of difference between compared images.
prevRect
Contains a pointer to a rectangle defining the portion of the previous image to use for temporal compression. The compressor uses this portion of the previous image as the basis of comparison with the current image. This rectangle must be the same size as the source rectangle you specify with the srcRect parameter to the CompressSequenceBegin function. To get the boundary of a source pixel map, set this parameter to nil .

DESCRIPTION

When you start compressing a sequence, you may assign a previous frame buffer and rectangle with the prev and prevRect parameters to the CompressSequenceBegin function, respectively. If you specified a nil value for the prev parameter, the compressor allocates an offscreen buffer for the previous frame. In either case you may use this function to assign a new previous frame buffer.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

Memory Manager errors

SetCSequenceFlushProc

The SetCSequenceFlushProc function lets you assign a data-unloading function to a sequence.

pascal OSErr SetCSequenceFlushProc (ImageSequence seqID,
                                         ICMFlushProcRecordPtr flushProc,
                                         long bufferSize);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
flushProc
Points to a data-unloading function structure. If there is not enough memory to store the compressed image, the compressor calls a function you provide that unloads some of the compressed data (see "Data-Unloading Functions," for more information on the data-unloading structure). If you have not provided a data-unloading function, set this parameter to nil . In this case, the compressor writes the entire compressed image into the memory location specified by the data parameter to the CompressSequenceFrame function (described on CompressSequenceFrame ).
bufferSize
Specifies the size of the buffer to be used by the data-unloading function specified by the flushProc parameter. If you have not specified a data-unloading function, set this parameter to 0.

DESCRIPTION

Data-unloading functions allow compressors to work with images that cannot fit in memory. During the compression operation, the compressor calls the data-unloading function whenever it has accumulated a specified amount of compressed data. Your data-unloading function then writes the compressed data to some other device, freeing buffer space for more compressed data. The compressor starts using the data-unloading function with the next image in the sequence. See "Spooling Compressed Data" for more information.

There is no parameter to the CompressSequenceBegin function (described on CompressSequenceBegin ) that allows you to assign a data-unloading function to a sequence.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified

GetCSequencePrevBuffer

The GetCSequencePrevBuffer function determines the location of the previous image buffer allocated by the compressor.

pascal OSErr GetCSequencePrevBuffer (ImageSequence seqID,
                                          GWorldPtr *gworld);
seqID
Contains the unique sequence identifier that was returned by the CompressSequenceBegin function (described on CompressSequenceBegin ).
gworld
Contains a pointer to a field to receive a pointer to the structure of type GWorld that describes the graphics world for the image buffer. If the compressor has allocated an offscreen image buffer, the compressor returns an appropriate pointer to the graphics world (of type GWorldPtr ) in the field referred to by this parameter. If the compressor has not allocated a buffer, the function returns an error result code.
You should not dispose of this graphics world--the returned pointer refers to a buffer that the Image Compression Manager is using.

DESCRIPTION

If you do not specify a previous image buffer with the prev parameter to the CompressSequenceBegin function, the compressor allocates an offscreen graphics world for you. Your program can obtain access to the pixel map in that graphics world by calling this function.

Note that the GetCSequencePrevBuffer function only returns information about buffers that were allocated by the compressor. You cannot use this function to determine the location of a buffer you have provided.

RESULT CODES

noErr

0

No error

paramErr

-50

Invalid parameter specified


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next